#include<stdio.h>
void main()
{
	char a[20];
	int n,i=0,t;
	scanf("%d%d",&n,&t);
	while(n!=0)
	{
		if(n%t>9)
			a[i]=n%t-10+'A';
		else a[i]=n%t+'0';
		n=n/t;
		i++;
	}
	i--;
	for(;i>=0;i--)
		printf("%c",a[i]);
}

